#ifndef NOTEMGRFORM_H
#define NOTEMGRFORM_H

#include <QWidget>

class QListWidgetItem;

namespace Ui {
class NoteMgrForm;
}

class NoteMgrForm : public QWidget
{
    Q_OBJECT

    enum NOTE_DATA_ROLE{
        NDR_ID = Qt::UserRole,
        NDR_CONTENT = Qt::UserRole + 1,
        NDR_CREATE_TIME = Qt::UserRole + 2,
        NDR_LAST_EDIT_TIEM = Qt::UserRole + 3,
        NDR_MODIFY_TAG = Qt::UserRole + 4
    };

public:
    explicit NoteMgrForm(QWidget *parent = 0);
    ~NoteMgrForm();

protected:
    void closeEvent(QCloseEvent * event);

private slots:
    void titleListContextMenuRequested(const QPoint & pos);
    void noteContentChanged();
    void on_btnReturn_clicked();

    void on_lwTitles_itemDoubleClicked(QListWidgetItem *item);

    void on_actAddNote_triggered();

    void on_actDelNote_triggered();

    void on_btnSave_clicked();

private:
    bool initTable();
    void readNotes();
    bool saveNotes();
    bool saveNote(int &id, QString title, QString content, qint64 lastTime, qint64 crtTime);
    bool removeNote(int id);
    void recordNoteContent();

    Ui::NoteMgrForm *ui;
    QList<int> delNoteIds;  //被删除的笔记id列表

};

#endif // NOTEMGRFORM_H
